package com.jellyfishumbrella.GL;

public class Plane {
	Vector3d orig;
	Vector3d up;
	Vector3d right;
	Normal normal;
	
	double A,B,C,D;// Ax + By + Cz + D = 0
	// A,B,C is normal
	// substitute to find D

	public Plane(Vector3d orig, Vector3d up, Vector3d right){
		this.orig = orig;
		this.up = up;
		this.right = right;
		normal.cross(up,right);
		
		determineEquation();
	}
	
	public Plane(Vector3d orig, Normal normal){
		this.orig = orig;

		this.normal = normal;
		
		determineEquation();
	}
	
	private void determineEquation(){
		A = normal.x;
		B = normal.y;
		C = normal.z;
		D = -(A*orig.x + B*orig.y + C*orig.z);
		System.out.println("A: " + A+" B: "+B+" C: "+C+" D: "+D);
	}
	
	public double classifyPoint(Vertex p){
		return A*p.x()+B*p.y()+C*p.z()+D;
	}
}
